package com.zsummer.design.structure.bridge;

/**
 * @author zsummer
 * 2020/3/26 7:38
 * 桥接模式
 */
public class Client {
    public static void main(String[] args) {
        Hero strongHero = new StrongHero();
        strongHero.setSkill(new Definse());
        strongHero.show();
    }
}

/**
 * 实现化角色
 */
interface Skill {
    String showSkill();
}

/**
 * 具体实现化
 */
class Definse implements Skill{

    @Override
    public String showSkill() {
        return "definse";
    }
}

/**
 * 抽象化角色
 */
abstract class Hero {
    Skill skill;

    void setSkill(Skill skill) {
        this.skill = skill;
    }

    abstract void show();
}

/**
 * 扩展抽象化角色
 */
class StrongHero extends Hero{

    @Override
    void show() {
        System.out.println("strong hero with " + this.skill.showSkill());
    }
}
